<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/15
 * Time: 14:04
 */

namespace app\common\model;

use think\Model;

class StickPay extends Model
{
    protected $name = "stick_pay";
    public function getStickPayList($where, $filed = "*", $limit = 20, $request, $keyword) {
        if ($keyword) {
            $data = $this->alias('sp')
                ->join('stick_user su', 'sp.user_id = su.user_id', 'left')
                ->field($filed)
                ->where($where)
                ->whereOr('su.user_id', $keyword)
                ->whereOr('su.name', $keyword)
                ->whereOr('sp.id', $keyword)
                ->whereOr('su.phone', $keyword)
                ->order('sp.create_time desc')
                ->paginate($limit, false, ['query' => $request->get()]);
        } else {
            $data = $this->alias('sp')
                ->join('stick_user su', 'sp.user_id = su.user_id', 'left')
                ->field($filed)
                ->where($where)
                ->order('sp.create_time desc')
                ->paginate($limit, false, ['query' => $request->get()]);
        }

        return $data;
    }


    public function updateStatus($where, $data) {

        $res = $this->update($data)->where($where);

        return $res;

    }
}